home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / lib / tk / demos / mkIcon.tcl < prev    next >
Encoding:
Text File  |  1995-07-21  |  1.5 KB  |  44 lines

  1. # mkIcon w
  2. #
  3. # Create a top-level window that displays a bunch of iconic
  4. # buttons.
  5. #
  6. # Arguments:
  7. #    w -    Name to use for new top-level window.
  8.  
  9. proc mkIcon {{w .icon}} {
  10.     global tk_library
  11.     catch {destroy $w}
  12.     toplevel $w
  13.     dpos $w
  14.     wm title $w "Iconic Button Demonstration"
  15.     wm iconname $w "Icons"
  16.     message $w.msg -font -Adobe-times-medium-r-normal--*-180* -aspect 300 \
  17.         -text "This window shows three buttons that display bitmaps instead of text.  On the left is a regular button, which changes its bitmap when you click on it.  On the right are two radio buttons.  Click the \"OK\" button when you're done."
  18.     frame $w.frame -borderwidth 10
  19.     button $w.ok -text OK -command "destroy $w"
  20.     pack $w.msg -side top
  21.     pack $w.frame $w.ok -side top -fill x
  22.  
  23.     button $w.frame.b1 -bitmap @$tk_library/demos/bitmaps/flagdown  \
  24.         -command "iconCmd $w.frame.b1"
  25.     frame $w.frame.right
  26.     pack $w.frame.b1 $w.frame.right -side left -expand yes
  27.  
  28.     radiobutton $w.frame.right.b2 -bitmap @$tk_library/demos/bitmaps/letters \
  29.         -variable letters
  30.     radiobutton $w.frame.right.b3 -bitmap @$tk_library/demos/bitmaps/noletters \
  31.         -variable letters
  32.     pack $w.frame.right.b2 $w.frame.right.b3 -side top -expand yes
  33. }
  34.  
  35. proc iconCmd {w} {
  36.     global tk_library
  37.     set bitmap [lindex [$w config -bitmap] 4]
  38.     if {$bitmap == "@$tk_library/demos/bitmaps/flagdown"} {
  39.     $w config -bitmap @$tk_library/demos/bitmaps/flagup
  40.     } else {
  41.     $w config -bitmap @$tk_library/demos/bitmaps/flagdown
  42.     }
  43. }
  44.